import 'dart:convert';

import 'package:flutter/widgets.dart';
import 'package:crypto/crypto.dart';
import 'package:convert/convert.dart';

class NeteaseCloudMusicApiUtils {
  static String generateMd5({required dynamic data}) {
    List<int> content = new Utf8Encoder().convert(data.toString());
    Digest digest = md5.convert(content);
    return hex.encode(digest.bytes);
  }

  static bool hasMd5({required String md5String}) {
    return RegExp(r'^[a-zA-Z0-9]{32}$').hasMatch(md5String);
  }
}